﻿namespace cursor_movement_game
{
    internal class program
    {
        /// <summary>
        /// cursor_movement_game
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //定义整型x、y及坐标（0，0）
            int x = 0;
            int y = 0;
            ConsoleKey input;
            //设置背景颜色
            Console.BackgroundColor = ConsoleColor.Blue;
            do
            {
                //在坐标（x,y)处输出hello
                Console.Clear();
                Console.SetCursorPosition(x, y);
                Console.Write("hello");
                //接受用户输入
                input = Console.ReadKey(true).Key;
                //根据用户输入调整x,y
                switch (input)
                {
                    case ConsoleKey.A:
                        if (x > 0)
                            x--;
                        break;
                    case ConsoleKey.S:
                        if (y < 80)
                            y++;
                        break;
                    case ConsoleKey.D:
                        if (x < 80)
                            x++;
                        break;
                    case ConsoleKey.W:
                        if (y > 0)
                            y--;
                        break;
                    default:
                        break;
                }
                //回到第二步
            } while (input != ConsoleKey.Enter);
        }
    }

}